$(function () {
    updateTime()

    // 每秒钟更新一次时间
    setInterval(updateTime, 1000);
})

function updateTime() {
    var now = new Date();
    var y = now.getFullYear();
    var m = now.getMonth() + 1;
    if (m < 10) {
        m = "0" + m
    }
    var d = now.getDate();
    if (d < 10) {
        d = "0" + d
    }
    var hours = now.getHours();
    var minutes = now.getMinutes();
    var seconds = now.getSeconds();
    var timeString = y + "-" + m + "-" + d + " " + hours.toString().padStart(2, '0') + ":" +
        minutes.toString().padStart(2, '0') + ":" +
        seconds.toString().padStart(2, '0');
    document.getElementById("time").innerHTML = timeString;
}